import { instanceS } from "../utils/request"
import {PhoneCodeData, RegisterParamsData, ResLoginData, ResUserInfoData,ResOrderListData, ResRegisterData} from '../types/center'

/**
 * @description 注册获取短信验证码
 * @param phone 电话号码
 * @returns 验证码
 */
export const reqPhoneCode = (phone:string) => {
  return instanceS.get<any,PhoneCodeData>(`/api/user/passport/sendCode/${phone}`)
}

/**
 * @description 注册账号
 * @param data 电话号码,验证码,密码
 * @returns null
 */
export const reqRegister = (data:RegisterParamsData) => {
  return instanceS.post<any,ResRegisterData>(`/api/user/passport/register`,data)
}

/**
 * @description 登录账号
 * @param data 手机号和密码
 * @returns 
 */
export const reqLogin = (data:RegisterParamsData) => {
  return instanceS.post<any,ResLoginData>(`/api/user/passport/login`,data)
}

/**
 * @description 获取用户信息
 * @returns ResUserInfoData
 */
export const reqUserInfo = () => {
  return instanceS.get<any,ResUserInfoData>(`/api/user/passport/auth/getUserInfo`)
}


export const reqOrderList = (page:number,limit:number) => {
  return instanceS.get<any,ResOrderListData>(`/api/order/auth/${page}/${limit}`)
}